Using jquery with Google maps
Download jQuery 1.4.X or higher and optionally jQuery UI 1.8.X or higher or use Googles or Microsofts CDN.
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js""></script> <script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.map.js"></script> <script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.map.microdata.js"></script>
or
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> <script type="text/javascript" src="PATH_TO_PLUGIN/jquery.fn.gmap.js"></script> <script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.map.microdata.js"></script>
<script type="text/javascript"> $(function() { $('#map_canvas').gmap().bind('init', function () { $('#map_canvas').gmap('microdata', 'http://data-vocabulary.org/Event', function(result, item, index) { var latlng = new google.maps.LatLng(result.properties.location[0].properties.geo[0].properties.latitude[0], result.properties.location[0].properties.geo[0].properties.longitude[0]); var content = '<div class="iw"><img class="iw-photo shadow-all" src="'+result.properties.photo[0]+'"/><h1 class="iw-summary">'+result.properties.summary[0]+'</h1><p class="iw-description">'+result.properties.description[0]+'</p><div class="clear"><div></div>'; $('#map_canvas').gmap('addMarker', { 'bounds':true, 'position': latlng, 'content': content }, function(map, marker) { $(item).addClass('clickable'); $(item).click(function() { $(marker).triggerEvent('click'); return false; }); }).click( function() { $('#map_canvas').gmap('openInfoWindow', { 'content': $(this)[0].content }, this ); }); }); }); }); </script>
More Google maps and jQuery examples
- Google maps with jQuery mobile example
- Microformats, Google streetview and jQuery dialog example
- Click and drag events with Google geo search example
- Import markers with JSON example
- Import markers with microformats example
- Import markers with RDFa example
- Import markers with Google Fusion tables
- Multiple maps on a single page example
- Google maps and jQuery example
- Filter markers example